<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        /* 
            *****
            ****
            ***
            **
            *
            思路：双重for 循环，外层控制行，内层控制列
            i       num 的最大值
            0           5
            1           4
            2           3
            3           2
            4           1
            
            i + num = 5
            num = 5 - i;
        */
        let num1 = prompt('请输入行数');
        for (let i = 0; i < num1; i++) {
            let star = ' ';
            for (let j = 0; j < num1 - i; j++) {
                star = star + '*';
            }
            console.log(star);
        }

        console.log(`-----------案例---------`);
        /*
            *
            **
            ***
            ****
            *****

                 *
                **
               ***
              ****
             *****
        */
        let num2=prompt('请输入行数');
        for(let i = num2; i>0;i--){
         let star='';
         for (let j =0;j <= num2-i;j++){
             star = star + '*';
         }
         console.log(star);
        }
        let num=prompt('请输入行数');
        for(let i = num; i>0;i--){
         let star='';
   
         for(let k =1;k < i;k++){
            star=star+" ";
         }
         for (let j =0;j <=num-i;j++){
             star = star + '*';
         }
         console.log(star);
        } 
    </script>
</body>

</html>